package com.dyb.recuitment.common;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result implements Serializable {

    private String code;  // 操作响应代码
    private Object data; // 操作响应数据
    private String msg; // 操作响应提示

    public static Result success(Object data) {
        Result result = new Result();
        result.setCode("1");
        result.setData(data);
        result.setMsg("操作成功!");
        return result;
    }

    public static Result success(Object data, String msg) {
        Result result = new Result();
        result.setCode("1");
        result.setData(data);
        result.setMsg(msg);
        return result;
    }

    public static Result warning(Object data) {
        Result result = new Result();
        result.setCode("0");
        result.setData(data);
        result.setMsg("操作异常!");
        return result;
    }

    public static Result warning(Object data, String msg) {
        Result result = new Result();
        result.setCode("0");
        result.setData(data);
        result.setMsg(msg);
        return result;
    }

    public static Result failure(Object data) {
        Result result = new Result();
        result.setCode("-1");
        result.setData(data);
        result.setMsg("操作失败!");
        return result;
    }

    public static Result failure(Object data, String msg) {
        Result result = new Result();
        result.setCode("-1");
        result.setData(data);
        result.setMsg(msg);
        return result;
    }

}
